<?php
namespace app\index\controller;
use \think\Request;
use app\index\model\ConnectUnit;
use app\index\model\ConnectUser;
use \think\Session;

class Index extends \think\Controller
{
    public function index()
    {
		$request = Request::instance();
		$where = $request->param();
		Session::set('book',$where['book']);
		$Unit = new ConnectUnit;
		$info = $Unit->where($where)->select();
		if(sizeof($info) == 0){

		}else{
			$info=json_decode(json_encode($info),true);
			$this->assign('book',$where['book']);
			$this->assign('info',$info);
			return $this->fetch('index');
		}
	}
	public function login()
	{
		return $this->fetch('login');
	}
	public function logining()
	{
		$request = Request::instance();
		$user = $request->param();
		$where['stuid'] = $user['Username'];
		$where['password'] = $user['Password'];
		$user = new ConnectUser;
		$info= $user->where($where)->find();
		$info=json_decode(json_encode($info),true);
		if(empty($info)){
			echo 0;
		}else{
			Session::set('info',$info);
			echo 1;
		}
	}

}
